home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Technotools
/
Technotools (Chestnut CD-ROM)(1993).ISO
/
lang_c
/
cgraphix
/
kdrawsqr.c
< prev
next >
Wrap
Text File
|
1986-05-27
|
2KB
|
107 lines
/* «RM120»«PL99999»«TS4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64,68,72,76» */
#include <stdio.h>
#define EXTERN extern
#include <typedef.h>
static void DSC1(x1, x2, y)
int x1, x2, y;
{
if (clip(&x1, &y, &x2, &y)) {
if (LineStyleGlb == 0) {
DrawStraight(x1, x2, y);
}
else {
DrawLine((double)x1, (double)y, (double)x2, (double)y);
}
}
}
void DrawSquareC(x1, y1, x2, y2, fill)
int x1, y1, x2, y2, fill;
{
int i;
if (!fill) {
DSC1(x1, x2, y1);
DrawLineClipped(x2, y1, x2, y2);
DSC1(x1, x2, y2);
DrawLineClipped(x1, y2, x1, y1);
}
else {
for (i = y2; i <= y1; i++)
DSC1(x1, x2, i);
}
}
static void DS(x1, x2, y)
int x1, x2, y;
{
if (LineStyleGlb == 0) {
DrawStraight(x1, x2, y);
}
else {
DrawLineDirect(x1, y, x2, y);
}
}
static void DSC(x1, x2, y)
int x1, x2, y;
{
if (clip(&x1, &y, &x2, &y))
DS(x1, x2, y);
}
void DrawSqr(x1, y1, x2, y2, fill)
int x1, y1, x2, y2, fill;
{
int i;
if (!fill) {
DS(x1, x2, y1);
DrawLineDirect(x2, y1, x2, y2);
DS(x1, x2, y2);
DrawLineDirect(x1, y2, x1, y1);
}
else {
for (i = y1; i <= y2; i++)
DS(x1, x2, i);
}
}
void DrawSquare(X1, Y1, X2, Y2, fill)
double X1, Y1, X2, Y2;
int fill;
{
int i, x1loc, y1loc, x2loc, y2loc;
int DirectModeLoc;
if (DirectModeGlb) {
DrawSqr((int)(X1),(int)(Y1),(int)(X2),(int)(Y2),fill);
}
else {
DirectModeLoc = DirectModeGlb;
DirectModeGlb = TRUE;
x1loc = WindowX(X1);
y1loc = WindowY(Y1);
x2loc = WindowX(X2);
y2loc = WindowY(Y2);
if (!fill) {
DSC(x1loc, x2loc, y1loc);
DrawLineClipped(x2loc, y1loc, x2loc, y2loc);
DSC(x1loc, x2loc, y2loc);
DrawLineClipped(x1loc, y2loc, x1loc, y1loc);
}
else
for (i = y1loc; i <= y2loc; i++)
DSC(x1loc,x2loc,i);
DirectModeGlb = DirectModeLoc;
}
}